package com.jrx.anytxn.transaction.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.param.entity.PrPenaltyRateTable;
import com.jrx.anytxn.transaction.bean.CastAccountBean;
import com.jrx.anytxn.transaction.bean.CastAccountTransactionBean;
import com.jrx.anytxn.transaction.bean.CastWaiveAccountBean;
import com.jrx.anytxn.transaction.bean.DelqParamBean;
import com.jrx.anytxn.transaction.entity.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface IAccountService {

    /**
     * 累计账户抛账  抛出交易账户
     *
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amInterestAccrualInfo
     * @return
     * @throws TxnBizException
     */
    CastAccountTransactionBean castInterestAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo, AmInterestAccrualInfo amInterestAccrualInfo, Date businessDate,boolean batchFlag) throws TxnException;

    /**
     *  抛账  抛出本金账户
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amRepaymentPlanInfo
     * @param delqParamBean
     * @param businessDate
     * @return
     * @throws TxnBizException
     */
    CastAccountTransactionBean castPrincipalAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                                    AmRepaymentPlanInfo amRepaymentPlanInfo, DelqParamBean delqParamBean, Date businessDate) throws TxnException;

    /**
     * 抛账  抛出利息累计账户
     * @param amRepaymentPlanInfo
     * @param amAccountMainInfo
     * @param amLoanAccountInfo
     * @param amLoanMainInfo
     * @param accrualBaseAmount
     * @param delqParamBean
     * @return
     * @throws TxnBizException
     */
    AmInterestAccrualInfo castInterestAccrualAccount(AmRepaymentPlanInfo amRepaymentPlanInfo,
                                                     AmAccountMainInfo amAccountMainInfo,
                                                     AmLoanAccountInfo amLoanAccountInfo,
                                                     AmLoanMainInfo amLoanMainInfo, BigDecimal accrualBaseAmount,
                                                     DelqParamBean delqParamBean) throws TxnBizException;

    /**
     * 抛出罚息、复利累计账户
     * @param amRepaymentPlanInfo
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param penaltyRateTable
     * @param delqParamBean
     * @return
     * @throws TxnBizException
     */
    List<AmInterestAccrualInfo> castPenAndComAccrualAccount(AmRepaymentPlanInfo amRepaymentPlanInfo, AmLoanMainInfo amLoanMainInfo,
                                                            AmLoanAccountInfo amLoanAccountInfo, PrPenaltyRateTable penaltyRateTable,
                                                            DelqParamBean delqParamBean,Date intrBeginDate,Date businessDate) throws TxnBizException;

        /**
         * 抛账  抛分期费用账户
         *
         * @param amLoanMainInfo
         * @param amLoanAccountInfo
         * @param amRepaymentPlanInfo
         * @param businessDate
         * @return
         * @throws TxnBizException
         */
    CastAccountTransactionBean castInstallmentFeeAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                                             AmRepaymentPlanInfo amRepaymentPlanInfo, Date businessDate) throws TxnException;

    /**
     * 抛账   抛当期本金、费用、利息累计
     *
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amRepaymentPlanInfoList
     * @param businessDate
     * @param isValid
     * @return
     * @throws TxnBizException
     */
    CastAccountBean castTxnAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                   List<AmRepaymentPlanInfo> amRepaymentPlanInfoList, Date businessDate,
                                   Boolean isValid) throws TxnException;


    /**
     * 得到当期还款计划明细
     *
     * @param tenor
     * @param amRepaymentPlanInfoList
     * @return
     */
    AmRepaymentPlanInfo getRepaymentPlanInfo(Integer tenor, List<AmRepaymentPlanInfo> amRepaymentPlanInfoList);


    /**
     * 获取订单计划剩余本金金额
     *
     * @param repaymentPlanInfoList
     * @param billingTenor
     * @return
     */
    BigDecimal getPlanPrinBalance(List<AmRepaymentPlanInfo> repaymentPlanInfoList, Integer billingTenor);

    /**
     * 抛账  抛还款费用账户
     *
     * @param amLoanMainInfo
     * @param feeTxnCode
     * @param feeAmt
     * @param businessDate
     * @return
     */
    CastAccountTransactionBean castPaymentFeeAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo, String feeTxnCode, BigDecimal feeAmt, Date businessDate,String liabilityFlag) throws TxnException;

    /**
     * 抛账  抛利息交易账户
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amRepaymentPlanInfo
     * @param delqParamBean
     * @param businessDate
     * @return
     * @throws TxnBizException
     */
    CastAccountTransactionBean castIntrAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                               AmRepaymentPlanInfo amRepaymentPlanInfo, DelqParamBean delqParamBean, Date businessDate) throws TxnException;

    /**
     * 获取账户id
     *
     * @param accountType 账户类型
     * @param tenantId    租户id
     * @param customerId  客户id
     * @return
     */
    String getAccountId(String accountType, String tenantId, String customerId);


    /**
     * 生成延滞交易账户
     *
     * @param amLoanMainInfo
     * @param amRepaymentPlanInfo
     * @param businessdate
     * @param delqDays
     * @return
     */
    AmDelinquencyInfo generateDelinquencyInfo(AmLoanMainInfo amLoanMainInfo, AmRepaymentPlanInfo amRepaymentPlanInfo, Date businessdate, Integer delqDays) throws TxnBizException;

    /**
     * 核销抛账  抛出本金账户
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amRepaymentPlanInfo
     * @param delqParamBean
     * @param businessDate
     * @return
     * @throws TxnBizException
     */
    CastAccountTransactionBean castPrincipalAccountByChargeoff(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                                    AmRepaymentPlanInfo amRepaymentPlanInfo, DelqParamBean delqParamBean, Date businessDate) throws TxnException;


    /**
     * 核销累计账户抛账  抛出交易账户
     *
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amInterestAccrualInfo
     * @return
     * @throws TxnBizException
     */
    CastAccountTransactionBean castInterestAccountByChargeoff(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo, AmInterestAccrualInfo amInterestAccrualInfo, Date businessDate,String reasonCode) throws TxnException;

    /**
     * 抛帐
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param waiveRepaymentPlanInfoList
     * @param amRepaymentPlanInfoList
     * @param businessDate
     * @param isValid
     * @return
     * @throws TxnException
     */
    CastWaiveAccountBean castTxnWaiveAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo, List<AmWaiveRepaymentPlanInfo> waiveRepaymentPlanInfoList,List<AmRepaymentPlanInfo> amRepaymentPlanInfoList, Date businessDate, Boolean isValid) throws TxnException;

    /**
     * 贴息累计抛帐
     * @param amWaiveRepaymentPlanInfo
     * @param amLoanAccountInfo
     * @param amLoanMainInfo
     * @param accrualBaseAmount
     * @param delqParamBean
     * @return
     * @throws TxnBizException
     */
    AmInterestAccrualInfo castWaiveInterestAccrualAccount(AmWaiveRepaymentPlanInfo amWaiveRepaymentPlanInfo, AmLoanAccountInfo amLoanAccountInfo, AmLoanMainInfo amLoanMainInfo, BigDecimal accrualBaseAmount, DelqParamBean delqParamBean) throws TxnBizException;

    /**
     * 贴息累计账户抛账  抛出贴息交易账户
     * @param amLoanMainInfo
     * @param amLoanAccountInfo
     * @param amInterestAccrualInfo
     * @param businessDate
     * @return
     * @throws TxnException
     */
    CastAccountTransactionBean castWaiveInterestAccount(AmLoanMainInfo amLoanMainInfo, AmLoanAccountInfo amLoanAccountInfo,
                                                               AmInterestAccrualInfo amInterestAccrualInfo, Date businessDate) throws TxnException;

    /**
     * 根据原累计账户生成表外累计账户
     * @param accuAcct
     * @param bussinessDate
     * @return
     * @throws TxnBizException
     */
    AmInterestAccrualInfo castNonInterestAccrualAccount(AmInterestAccrualInfo accuAcct, Date bussinessDate) throws TxnBizException;

    /**
     * 账单部分还款抛出利息累计账户
     *
     * @param amRepaymentPlanInfo
     * @param amLoanAccountInfo
     * @param amLoanMainInfo
     * @param accrualBaseAmount
     * @param delqParamBean
     * @return
     * @throws TxnBizException
     */
    AmInterestAccrualInfo castInterestAccrualAccount(AmRepaymentPlanInfo amRepaymentPlanInfo, AmLoanAccountInfo amLoanAccountInfo,
                                                     AmLoanMainInfo amLoanMainInfo, BigDecimal accrualBaseAmount, DelqParamBean delqParamBean,BigDecimal maxIntrAmt) throws TxnBizException;
}
